import java.util.ArrayList;

public class offer54 {
    //二叉搜索树第k大节点
    ArrayList<Integer> list = new ArrayList<>();
    public int kthLargest(TreeNode root, int k) {
        inorder(root);
        return list.get(list.size() - k);
    }

    private void inorder(TreeNode root) {
        if(root == null) {
            return;
        }
        inorder(root.left);
        list.add(root.val);
        inorder(root.right);
    }
}
